Handling API Requests

  • An abstract class that represents a request to the Spotify Web API.

    An SKRequest object encapsulates the properties of an HTTP request, providing a convenient template for you to create, prepare, and send requests to the Web API. See the API Requests Guide for more details.

    See more

    Declaration

    Swift

    public class SKRequest
  • The callback handler for a request.

    Declaration

    Swift

    public typealias SKRequestHandler = (_ data: Data?, _ status: SKResponseStatus?, _ error: Error?) -> Void

    Parameters

    data

    The data (typically an encoded JSON object) returned by the request, if any. If the data returned represents an API-specific error object, that object will be provided via the error parameter instead.

    status

    The API-specific HTTP status code associated with the response. If the underlying URL request could not be completed successfully, or the URL response contained an unexpected status code, this parameter will be nil.

    error

    An error identifying if and why the request failed, or nil if the request was successful.

  • The callback handler for a request.

    Declaration

    Swift

    public typealias SKDecodableHandler<T> = (_ type: T?, _ error: Error?) -> Void

    Parameters

    type

    The type decoded from the JSON data returned by the request. If the type could not be decoded from the data received, the error parameter will provide details.

    error

    An error identifying if and why the request or decoding failed, or nil if the request was successful.

  • The callback handler for a request.

    Declaration

    Swift

    public typealias SKErrorHandler = (_ error: Error?) -> Void

    Parameters

    error

    An error identifying if and why the request or decoding failed, or nil if the request was successful.